import math

R = 6371  # Earth's radius in km

def hav(x):
    return (1-math.cos(x))/2

def ahav(x):
    return math.acos(1-2*x)

def havdr(theta1, lambda1, theta2, lambda2):
    havtheta=hav(theta2-theta1)+math.cos(theta1)*math.cos(theta2)*hav(lambda2-lambda1)
    return havtheta

if __name__ == '__main__':
    theta1 = float(input())/180*math.pi
    lambda1 = float(input())/180*math.pi
    theta2 = float(input())/180*math.pi
    lambda2 = float(input())/180*math.pi
    havtheta = havdr(theta1, lambda1, theta2, lambda2)
    ahavtheta = ahav(havtheta)
    d = R*ahavtheta
    print(f'{round(d,4):.4f}km')
